library CorpsmanVitalSigns initializer init requires LegacySystem

	private function Trig_CorpsmanVitalSigns_Conditions takes nothing returns boolean
		return GetSpellAbilityId()=='A03D'
	endfunction

	private function Trig_CorpsmanVitalSigns_Actions takes nothing returns nothing
		local integer i = 1
		local integer a = 0
		local integer attention = 0
		call DisplayTimedTextToPlayer( GetLocalPlayer(), 0.0, 0.0, 5.0, "|cfff3ad00Vital Signs - 3rd Platoon, Echo Company|r" )
		loop
			exitwhen i > udg_Players
			if udg_Hero[udg_Sorted[i]]!=null then
				set attention = 0
				if GetUnitAbilityLevel(udg_Hero[udg_Sorted[i]],'B00A')>0 then
					set a = 1
					set attention=1
					call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 5.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r has open wounds." )
				endif
				if GetUnitAbilityLevel(udg_Hero[udg_Sorted[i]],'Bslo')>0 then
					set a = 1
					set attention=1
					call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 5.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r has a fracture." )
				endif
				if PoisonCheck(udg_Hero[udg_Sorted[i]]) then
					set a = 1
					set attention=1
					call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 5.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r is poisoned." )
				endif
				if GetWidgetLife(udg_Hero[udg_Sorted[i]])<=175.0 then
					set a = 1
					if GetUnitTypeId(udg_Hero[udg_Sorted[i]])=='h00E' then
						call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 8.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r is badly damaged." )
					else
						set attention=1
						call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 8.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r is badly injured." )
					endif
				endif
				if attention==1 then
					call PingMinimapEx(GetUnitX(udg_Hero[udg_Sorted[i]]), GetUnitY(udg_Hero[udg_Sorted[i]]), 5.0, 200, 0, 0, false)
				endif
			endif
			set i = i + 1
		endloop
		if a==0 then
			call DisplayTimedTextToPlayer( GetLocalPlayer(), 0.0, 0.0, 5.0, "All Marines are stable." )
		endif
	endfunction


	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger(  )
		call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT  )
		call TriggerAddCondition( t, Condition( function Trig_CorpsmanVitalSigns_Conditions) )
		call TriggerAddAction( t, function Trig_CorpsmanVitalSigns_Actions )
	endfunction

endlibrary